//
//  RWIconImage.m
//  04-ipadQQ
//
//  Created by 紫荆秋雪 on 16/4/7.
//  Copyright © 2016年 紫荆秋雪. All rights reserved.
//

#import "RWIconImage.h"
#import "RWIconButton.h"

@interface RWIconImage ()

/** 头像按钮 */
@property (nonatomic,weak) RWIconButton *imgBtn;

@end

@implementation RWIconImage

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    if (self) {
        
        //1、设置背景颜色
//        self.backgroundColor = [UIColor redColor];
        
        //2、创建 显示头像按钮
        RWIconButton *imgBtn = [[RWIconButton alloc] init];
        
        [self addSubview:imgBtn];
        self.imgBtn = imgBtn;
        
    }
    return self;
}

/**
 *  子控件布局
 */
- (void)layoutSubviews{

    [super layoutSubviews];
    
    if (Lanscape) {//横屏
        self.imgBtn.width = 100;
        self.imgBtn.height = self.imgBtn.width;
        self.imgBtn.x = (self.width - self.imgBtn.width) * 0.5;
        self.imgBtn.y = 50;
    }else {
    
        
        self.imgBtn.x = 5;
        self.imgBtn.y = 100;
        
        self.imgBtn.width = self.width - self.imgBtn.x * 2;
        self.imgBtn.height = self.imgBtn.width;
        
    }
}

@end
